<?php
/* @var $this ProductAdminController */
/* @var $model Product */

$this->breadcrumbs=array(
	'Products'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'Thêm sản phẩm', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#product-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Quản trị sản phẩm</h1>

<p>
Bạn có thể nhập điều kiện (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
hoặc <b>=</b>) để <?php echo CHtml::link('<b>Tìm kiếm<b>','#',array('class'=>'search-button')); ?>.
</p>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'product-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'product_id',
		'product_name',
		array(
            'name'=>'product_image',
            'type'=>'raw',
            'value'=>'CHtml::image($data->product_image,\'\',array(\'style\'=>\'max-width:150px\'))',
        ),
		array(
            'name'=>'product_price',
            'value'=>'number_format($data->product_price,0,\'\',\',\')',
        ),
        array(
            'name'=>'product_price_sale',
            'value'=>'number_format($data->product_price_sale,0,\'\',\',\')',
        ),
        'product_quantity',
		array(
            'name'=>'category_id',
            'value'=>'Category::model()->getCategoryName($data->category_id)',
        ),
		array(
            'name'=>'brand_id',
            'value'=>'($data->brand_id)?Brand::model()->getBrandName($data->brand_id):""',
        ),
        'product_timecreate',
        'product_view',
        /*
		'product_reviews',
		'product_desc',
		'product_timeupdate',
		'product_image1',
		'product_image2',
		'product_image3',
		'product_image4',
		'product_image5',
		'product_image6',
		'product_image7',
		'product_image8',
		'product_image9',
		'product_video',
		'url',
		*/
		array(
			'class'=>'CButtonColumn',
            'deleteConfirmation'=>CONFIRM_DELETE,
		),
	),
    'pager'=>array(
            'header'=>'',
    ),
    'emptyText'=>'Không tìm thấy sản phẩm',
)); ?>
